home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / Documentation / Development Notes / TroubleShooting / Runtime Assertions < prev   
Encoding:
Text File  |  1996-04-26  |  18.6 KB  |  276 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                      
  5. Runtime Assertions 
  6. ODF Release 1                                                                                                                                                             
  7.  
  8. This document regroups the most common assertions you might encounter. For each assertion the library, file and method are indicated along with a short explanation.
  9.  
  10.                                                                                                                                                                                      
  11. Can't register a class as archivable if it doesn't have RTTI                                            
  12.  
  13. Library:       ODFFoundation
  14. File:             FWArDyna.cpp
  15. Method:      FW_CPrivArchiver::AddNameToLabelPair
  16.  
  17. Explanation:  This error should never happen if you're using native RTTI.  If you're using ODF RTTI, then you've forgotten to use the FW_DECLARE_CLASS and FW_DEFINE_CLASS_Mx macros for a class that is being registered as archivable. If you get this error you'll need to figure out which class is being registered for archiving.  Since the RTTI isn't available it's not possible to get a class name string, but the four characer class label is available.  You'll need to get that information using a debugger.
  18.  
  19.  
  20.                                                                                                                                                                                      
  21. If an initialize function is registered, a destroy function must be too.                          
  22.  
  23. Library:        ODFFoundation
  24. File:              FWArDyna.cpp
  25. Method:      FW_SPrivArcFun::FW_SPrivArcFun
  26.  
  27. Explanation: Archivable classes can use one-step or two-step initialization.  Classes that use one-step initialization use just the "create" function, and do not use an "initialize" function (a NULL pointer is passed to the FW_REGISTER_ARCHIVABLE_CLASS macro).  If an initialize function is specified, the class is using two-step initialization.  Two-step initialization is a potential source of a resource-leak if an exception is thrown by the initialization function.  To prevent this leak, it is necessary to provide a destroy function to destroy the object created by the "create" function.  You'll get this assertion if you've provided a non-NULL initialize function but used a NULL destroy function.
  28.  
  29.  
  30.                                                                                                                                                                                      
  31. Object registry ID was not found in registry                                                  
  32.  
  33. Library:       ODFFoundation
  34. File:             FWArDyna.cpp
  35. Method:      FW_CPrivArchiver::PrivCreateObject
  36.  
  37. Explanation: If the above assertion fails, the most likely explanation is that some code reading from the stream is not in sync with some code used to create the stream. Another potential problem is that the stream contains a reference to a preregistered runtime object, but for some reason the object wasn't preregistered at runtime. This can be checked by using a debugger.  Was the object registry ID that failed lookup a negative ID used to preregister some object? Finally, a last possibility is that the stream of data has been corrupted in some other way.
  38.  
  39.  
  40.                                                                                                                                                                                      
  41. <Class Label ID> class not registered for archiving. Forgot FW_DO_NOT_DEAD_STRIP ?
  42.  
  43. Library:       ODFFoundation
  44. File:             FWArDyna.cpp
  45. Method:       ClassLabel_Create
  46.  
  47. Explanation: A class label ID was encountered in a stream for which no class has been registered.  Either you forgot the FW_REGISTER_ARCHIVABLE_CLASS macro, or the translation unit containing it wasn't linked into your part editor.  This might happen due to dead-stripping by the linker.  You can prevent dead-stripping of archivable classes using the FW_DO_NOT_DEAD_STRIP macro.  Call the macro for the archivable class from some function that you know will not be dead-stripped.  One such place is your part's Initialize method.  
  48.  
  49. In particular if you create views from resources remember to use FW_DO_NOT_DEAD_STRIP for all the view classes which are not referenced in your code.  You call it also in your frame's PostCreateViewFromStream method as ODF samples do.
  50.  
  51. Note: in the current version you may see the assertion message containing garbled characters between the 4 characters class label and the string "class not registered for archiving...", just ignore these characters.
  52.  
  53. Following is a correspondance table between class labels and ODF view and menu classes:
  54.  
  55.   Label   Class
  56.  
  57.   bscl     FW_CPrivBaseScroller
  58.   butn     FW_CButton
  59.   dlog     FW_CDialogFrame
  60.   edvw     FW_CEditView
  61.   gpbx     FW_CGroupBox
  62.   grbx     FW_CGrowBox
  63.   lbox     FW_CListBox
  64.   mnit     FW_CMenuItem
  65.   popm     FW_CPopupMenu
  66.   pdmn     FW_CPullDownMenu
  67.   rcls     FW_CRadioCluster
  68.   sbsc     FW_CScrollBarScroller
  69.   scbr     FW_CScrollBar
  70.   sclr     FW_CScroller
  71.   seit     FW_CSeparatorItem
  72.   stxt     FW_CStaticText
  73.   suit     FW_CSubMenuItem
  74.   suvw     FW_CSuperView
  75.   tgit     FW_CToggleItem
  76.   txit     FW_CTextItem
  77.  
  78.                                                                                                                                                                                      
  79. No registered archiving functions for class label
  80.  
  81. Library:       ODFFoundation
  82. File:             FWArDyna.cpp
  83. Method:     FW_CPrivArchiver::PrivCreateObject
  84.  
  85. Explanation: Under normal circumstances this assertion could only happen if the assertion "<Class Label ID>' class not registered for archiving. Forgot FW_DO_NOT_DEAD_STRIP ?" had already been triggered.  If you see this assertion and did not see the "Forgot FW_DO_NOT_DEAD_STRIP?" assertion, please report a bug to the ODF team.  See above for more information about this problem.
  86.  
  87.  
  88.                                                                                                                                                                                      
  89. Attempt to create object from stream with NULL create function
  90.  
  91. Library:       ODFFoundation
  92. File:             FWArDyna.cpp
  93. Method:      FW_CPrivArchiver::PrivCreateObject
  94.  
  95. Explanation: The archiving subsystem allows you to pass a NULL pointer in the place of the "create" function parameter.  However, if the archiver encounters a class label ID for such a class while reading from a stream then it will be unable to create the object.
  96.  
  97.  
  98.                                                                                                                                                                                      
  99. Class <className> has already been registered as archivable!
  100.  
  101. Library:       ODFFoundation
  102. File:             FWArDyna.cpp
  103. Method:      FW_CPrivArchiver::AddNameToLabelPair
  104.  
  105. Explanation: You probably have used the FW_REGISTER_ARCHIVABLE_CLASS macro twice for the same class.  If you want to register previous versions of the class, use the FW_REGISTER_PREV_VERSION_ARCHIVABLE_CLASS macro.
  106.  
  107.  
  108.                                                                                                                                                                                      
  109. Exception error, calling terminate()
  110.  
  111. Library:       ODFFoundation
  112. File:             FWExcImp.cpp
  113. Method:       DoTerminate
  114.  
  115. Explanation:  This message can only happen if you're using ODF exceptions, but the problem can happen with either native or ODF exceptions.  One way the problem can happen is to throw an exception inside a scope for which there is no active try block.  This might happen if you've created a SOM class and you implement one or more methods without a try block (ODF uses try blocks for all of it's SOM entry points).
  116.  
  117.  
  118.                                                                                                                                                                                      
  119. Why is an autodestruct object of class <classname> being constructed in a bad context?  See FWExcImp.cpp for possible causes.
  120.  
  121. Library:       ODFFoundation
  122. File:             FWExcImp.cpp
  123. Method:      FW_AutoConstructed
  124.  
  125. Explanation: Possible causes:
  126.      1) The autodestruct object is a member of another object which itself is not an autodestruct object. This other object is being allocated via new, not FW_NEW.  If so, this is a programmer error. Make the other object's class be autodestruct, and use FW_NEW.
  127.      2) This is a static object of a shared library that has just been loaded, and static constructors are being executed.  We have attempted to detect this condition and not report it as an error, but may not have eliminated it for all environments.  If this is the case, it is not a programming error.  You can safely continue execution. Note: if you move this code into an application (as opposed to a shared library), you may need to set FW_gInStaticInit to zero in your main() to inform this subsystem that static initialization is complete.
  128.      3) A case similar to 2) is possible.  If a static autodestruct object is declared in a function, the compiler is not obligated to initialize it at static initialization time, it can (and should) wait until the function is first called.  This case is very difficult to detect (without help from the compiler!).  It is not a programming error, and it is safe to continue excecution.
  129.      4) You are using threads and did not call FW_Thread_NoteSwitch when threads were switched.
  130.  
  131.  
  132.                                                                                                                                                                                      
  133. The autodestruct class <classname> is missing an FW_END_CONSTRUCTOR.
  134.  
  135. Library:       ODFFoundation
  136. File:             FWExcImp.cpp
  137. Method:      FW_AutoDestructed
  138.  
  139. Explanation: An FW_START_DESTRUCTOR is executing for a class that was constructed without an FW_END_CONSTRUCTOR.  Look at every constructor of the class <classname> and make sure it has an FW_END_CONSTRUCTOR.  Don't forget that the compiler might generate a copy constructor for you if you haven't declared one.  If you declare a class to be autodestruct, the compiler generated copy constructor  will not work; you must provide your own definition for the copy constructor.  Note that a compiler will also generate a default constructor, but only if you haven't declared any constructors.
  140.  
  141.  
  142.                                                                                                                                                                                      
  143. An autodestruct class is missing an FW_END_CONSTRUCTOR or FW_START_DESTRUCTOR. Likely candidates: <class1> and <class2> respectively.
  144.  
  145. Library:       ODFFoundation
  146. File:             FWExcImp.cpp
  147. Method:      FW_AutoDestructed
  148.  
  149. Explanation: This is similar to the message above, but it is a slightly different case, and harder to pinpoint at runtime.  The error is probably a missing FW_START_DESTRUCTOR in class2's destructor, but it may be a missing FW_END_CONSTRUCTOR in one of class1's constructors.
  150.  
  151.  
  152.                                                                                                                                                                                      
  153. The autodestruct class <classname> is missing an FW_START_DESTRUCTOR
  154.  
  155. Library:       ODFFoundation
  156. File:             FWExcImp.cpp
  157. Method:      FW_PrivTryBlockContext_Destroy
  158.  
  159. Explanation: A try block is going out of scope, but an autodestruct object of class <classname> in the try block's scope didn't clean up after itself by calling FW_START_DESTRUCTOR in it's destructor.  Find the destructor of the class (classname::~classname) and add the FW_START_DESTRUCTOR macro as the first line of the destructor. 
  160.  
  161.                                                                                                                                                                                      
  162. FW_CFixedAllocator: An object of type <classname> has not been deleted properly.
  163.  
  164. Library:       ODFOS
  165. File:             FWFixMem.cpp
  166. Method:       FW_CFixedAllocator::~FW_CFixedAllocator
  167.  
  168. Explanation: FW_CInkRep, FW_CStyleRep, FW_CFontRep, and FW_CPatternRep are allocated using a pool allocation scheme. This assertion indicates that on of this object has not been disposed when the allocator is disposed indicating the possibility of a memory leak. This situation can arise if you allocate a FW_CInk, FW_CStyle, FW_CFont or FW_CPattern object on the heap instead that on the stack an forgot to delete it. It could be also that you have one of this object as a field of another object that you are not disposing correctly.
  169.  
  170.  
  171.                                                                                                                                                                                      
  172. Environment has non-OpenDoc error
  173.  
  174. Library:       ODFOS
  175. File:             FWODExce.cpp
  176. Method:       FW_GetEvError
  177.  
  178. Explanation: Don't know what to do, it's a non-OpenDoc error.
  179.  
  180.  
  181.                                                                                                                                                                                      
  182. FW_CMenuItem::Read should never have been called
  183.  
  184. Library:       ODFOS
  185. File:             FWAMnuIt.cpp
  186. Method:       FW_CMenuItem::Read
  187.  
  188. Explanation: ODF is trying to instantiate a FW_CMenuItem which is an abstract base class. This could be the result of an error in your menu resource.  In particular you may have left an extra comma after the last  menu item (ODFRc doesn't catch this error at compile time).
  189.  
  190.  
  191.                                                                                                                                                                                      
  192. Trying to set the Facet Part Info of a non-display facet
  193.  
  194. Library:       ODFOS
  195. File:             FWFctInf.cpp
  196. Method:       FW_SetFacetRefCon
  197.  
  198. Explanation: FW_SetFacetRefCon was called passing as parameter a facet which is not a display facet. ODF uses the facet's PartInfo field to store information about the device. At part is not allow to set the PartInfo field of a non-display facets.
  199.  
  200.  
  201.                                                                                                                                                                                      
  202. Failed to load menu resource
  203.  
  204. Library:       ODFOS
  205. File:             FWMnuBar.cpp
  206. Method:       FW_SetFacetRefCon
  207.  
  208. Explanation:  We use this try-catch block purely to warn about a common mistake. If one forgets to add the resource containing their menus to their project, or passes in the wrong menu id, the above code will throw an exception that probably won't get caught until the SOM entry point from OpenDoc. OpenDoc will display an error dialog that isn't particularly helpful in diagnosing the problem.
  209.  
  210.  
  211.                                                                                                                                                                                      
  212. Your view or frame is not a FW_MReceiver, or you forgot RTTI macros
  213.  
  214. Library:       ODFFramework
  215. File:             FWControl.cpp
  216. Method:       FW_CControl::InitializeFromStream
  217.  
  218. Explanation:  If you get this error:
  219.                 -1- Make sure that the view or frame class you want to link to this control inherits from FW_MReceiver.
  220.                 -2- Make sure that you use a RTTI macro FW_DEFINE_CLASS_Mx, like:
  221.                                         FW_DEFINE_CLASS_M2(MyFrame, FW_CFrame, FW_MReceiver)
  222.         (See also ODF samples)
  223.  
  224.  
  225.                                                                                                                                                                                      
  226. in FW_MEventHandler::PrivInsert, handler already inserted
  227.  
  228. Library:       ODFFramework
  229. File:             FWEventH.cpp
  230. Method:       FW_MEventHandler::PrivInsert
  231.  
  232. Explanation:  FW_MEventHandler::AdoptEventHandler() has been called twice with the same event handler to adopt.
  233.  
  234.  
  235.                                                                                                                                                                                      
  236. Can't call SetLocation on a FW_CFrame
  237.  
  238. Library:       ODFFramework
  239. File:             FWFrame.cpp
  240. Method:      FW_CFrame::SetLocation
  241.  
  242. Explanation:  You cannot call SetLocation on a view of type FW_CFrame because it is the root view of your frame (i.e. its location is always 0, 0). 
  243.  
  244.  
  245.                                                                                                                                                                                      
  246. The part info resource is missing
  247.  
  248. Library:       ODFFramework
  249. File:             FWPart.cpp
  250. Method:       FW_CPart::Initialize
  251.  
  252. Explanation:  All ODF parts must have a PartInfo resource. You either forgot to include the resource in your project or passed the wrong ID to the FW_CPart constructor.
  253.  
  254.  
  255.                                                                                                                                                                                      
  256. Cannot use a ScrollBarScroller here, create a separate content view
  257.  
  258. Library:       ODFFramework
  259. File:             FWScrolr.cpp
  260. Method:       FW_CScrollBarScroller::PrivCheckFrame
  261.  
  262. Explanation: ODF doesn't authorize frames to use a scroller with scroll bars in case they don't have a separate content view, because the scroll bars will end up moving with the rest of the frame's content!  A frame which is its own content view can only use a basic FW_CScroller object, it can be scrolled with other mechanisms such as hand-scrolling or auto-scrolling.
  263.  
  264.  
  265.                                                                                                                                                                                      
  266. Failed to load view resource.
  267.  
  268. Library:       ODFFramework
  269. File:             FWSView.cpp
  270. Method:       FW_CSuperView::CreateSubViewsFromResource
  271.  
  272. Explanation:  We use this try-catch block purely to warn about a common mistake. If one forgets to add the resource containing their views to their project, or passes in the wrong view id, the above code will throw an exception that probably won't get caught until the SOM entry point from OpenDoc. OpenDoc will display an error dialog that isn't particularly helpful in diagnosing the problem.
  273.  
  274.  
  275. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  276. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.